<include file="public:header" />
<!--菜单添加-->
<ul id="mytab" class="nav nav-tabs" style="margin-top: 15px;">
    <li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
    <li class="active"><a href="#con1" data-toggle="tab">新会员</a></li>
    <!--<li><a href="#con2" data-toggle="tab">菜单添加1</a></li>-->
</ul>
<div id="tabContent" class="tab-content">
    <div class="tab-pane fade in active" id="con1">
        <div style="margin-top: 20px;">
            <form class="form-horizontal" role="form" action="{:u('superadmin/member/add')}" method="post">
                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">手机:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="text" class="form-control" name="mobile" id="mobile"
                               placeholder="请输入手机号">
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">密码:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="password" class="form-control" name="password" id="password"
                               placeholder="请输入密码">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">确认密码:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="password" class="form-control" name="repassword" id="repassword"
                               placeholder="请输入确认密码">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">会员名:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="text" class="form-control" name="username" id="username"
                               placeholder="请输入会员名">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">积分:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="text" class="form-control" name="score" id="score"
                               placeholder="请输入积分 eg: 1000">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label label-form">邮箱:</label>
                    <div class="col-sm-3 input-padding">
                        <input type="text" class="form-control" name="email" id="email"
                               placeholder="请输入邮箱">
                    </div>
                </div>


                <div class="form-group">
                    <button id="save" class="btn btn-primary btn-position">保存</button>
                </div>

            </form>

        </div>
    </div>
    <!--<div class="tab-pane fade" id="con2">-->
        <!--code-->
    <!--</div>-->
</div>


<include file="public:footer" />
<script>
$(document).ready(function(){
    $('#mytab a').click(function (e) {
        e.preventDefault()
        $(this).tab('show')
    })

    $('#save').click(function(){
        var name       = $.trim($('#username').val());
        var email      = $.trim($('#email').val());
        var mobile     = $.trim($('#mobile').val());
        var password       = $.trim($('#password').val());
        var repassword     = $.trim($('#repassword').val());

        if(!mobile)
        {
            $('#mobile').val('').focus();
            layer.tips('请输入手机号', '#mobile', {
                tips: [2, '#009f95'],
                time: 3000
            });
            return false;
        }


        if(!verifyformat(reg_mobile,mobile))
        {
            $('#mobile').focus();
            layer.tips('手机格式不正确', '#mobile', {
                tips: [2, '#009f95'],
                time: 3000
            });
            return false;
        }

        if(!password)
        {
            $('#password').val('').focus();
            layer.tips('请输入密码', '#password', {
                tips: [2, '#009f95'],
                time: 3000
            });
            return false;
        }

        if(!repassword)
        {
            $('#repassword').val('').focus();
            layer.tips('请输入确认密码', '#repassword', {
                tips: [2, '#009f95'],
                time: 3000
            });
            return false;
        }

        if(repassword != password)
        {
            $('#repassword').val('').focus();
            layer.tips('两次密码输入不一致', '#repassword', {
                tips: [2, '#009f95'],
                time: 3000
            });
            return false;
        }


        if(email)
        {
            if(!verifyformat(reg_email,email))
            {
                $('#email').focus();
                layer.tips('邮箱格式不正确', '#email', {
                    tips: [2, '#009f95'],
                    time: 3000
                });
                return false;
            }
        }





        //数据验证
        $.ajax({
            type: "POST",
            url: $('.form-horizontal').attr('action'),
            data: $('.form-horizontal').serialize(),
            dataType: "json",
            success:function(data){
                if(data.status)
                {
                    layer.msg(data.msg,{icon: 1,time:2000, shade: [0.1, '#ccc']})
                } else {
                    layer.msg(data.msg,{icon: 2,time:2000, shade: [0.1, '#ccc']})
                }

            }
        });
        return false;
    });



});
</script>
</body>
</html>